package com.xindaoapp.happypet.viewpager;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public class ViewPagerAdapter extends PagerAdapter {
	private final ViewPagerWindow[] windows;

	public ViewPagerAdapter(ViewPagerWindow[] windows) {
		super();
		this.windows = windows;
	}

	@Override
	public int getCount() {
		return windows.length;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView((View) object);
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		View view = windows[position].getView();
//		windows[position].loadData();
		container.addView(view);
		return view;
	}

	@Override
	public boolean isViewFromObject(View view, Object obj) {
		return view == obj;
	}

}
